package
{
    import loom.Application;    
    import loom.platform.Timer;
    import loom.animation.LoomTween;
    import loom.animation.LoomEaseType;

    import loom2d.display.StageScaleMode;

    import loom2d.display.Image;        
    import loom2d.textures.Texture;

    import loom2d.ui.SimpleLabel;

    import loom2d.events.Touch;
    import loom2d.events.TouchEvent;
    import loom2d.events.TouchPhase;

    import loom2d.math.Point;
    import loom2d.display.Sprite;

    public class TileDungeon extends Application
    {
        protected var bg:Sprite;
        protected var hero:Sprite;

        protected var titleLabel:SimpleLabel;
        protected var totalScore:SimpleLabel;

        protected var currentLevel:int = -1;
        protected var total:int;
        
        //protected var tiles:Array;
        //protected var bgTiles:Array;

        //protected var levelXML:XML;
        //protected var hud:HUD;
        
        public var mouseIsDown:Boolean = false;
        protected var collides:Boolean = false;
        protected var gameOver:Boolean = false;


        override public function run():void
        {
            super.run();

            // Automatic scaling
            layer.scaleMode = ScaleMode.LETTERBOX;

            // Setup anything else, like UI, or game objects.
            bg = CCSprite.createFromFile("assets/bg.png")
            bg.x = 240;
            bg.y = 160;
            bg.scale = 0.5;
            layer.addChild(bg);
            
            hero = CCSprite.createFromFile("assets/hero.gif");
            hero.x = 240;
            hero.y = 120;
            layer.addChild(hero);

            titleLabel = new Label("assets/Curse-hd.fnt");
            titleLabel.text = "Tile Dungeon";
            titleLabel.x = 240;
            titleLabel.y = 240;
            layer.addChild(titleLabel);

            total = 0;
            totalScore = new Label("assets/Curse-hd.fnt");
            totalScore.text = "0";
            totalScore.x = layer.designWidth/2;
            totalScore.y = 80;
            totalScore.scale = 0.75;
            layer.addChild(totalScore);

            update();
        }

        public function update():void
        {
            if (!gameOver)
            {
                total += 10;
                totalScore.text = total.toString();
            }
        }
    }
}